<%@ page import="report.Activity" %>
<%@page import="report.ActivityStatus"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <title>iPET - Atividades</title>
    </head>
    <body>
        <g:render template="/common/menuActivity" />
        <div id="text">
        <div class="body">
        	<h2>Editar atividade</h2>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${activityInstance}">
            <div class="errors">
                <g:renderErrors bean="${activityInstance}" as="list" />
            </div>
            </g:hasErrors>
            <g:form method="post" >
                <g:hiddenField name="id" value="${activityInstance?.id}" />
                <g:hiddenField name="version" value="${activityInstance?.version}" />
                <div class="dialog">
                    <table>
                        <tbody>
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="nature"><g:message code="activity.nature.label" default="Natureza" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: activityInstance, field: 'nature', 'errors')}">
                                    <g:textField name="nature" maxlength="128" value="${activityInstance?.nature}" />
                                </td>
                            </tr>
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="theme"><g:message code="activity.theme.label" default="Tema" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: activityInstance, field: 'theme', 'errors')}">
                                    <g:textField name="theme" maxlength="128" value="${activityInstance?.theme}" />
                                </td>
                            </tr>
                        	<tr class="prop">
                                <td valign="top" class="name">
                                    <label for="type"><g:message code="activity.months.label" default="Tipo" /></label>
                                </td>
                                 <td valign="top" class="value ${hasErrors(bean: activityInstance, field: 'type', 'errors')}">
                                 	<g:select name="type" from="${['Ensino', 'Extensão', 'Pesquisa', 'Coletiva']}" value="${activityInstance?.type}"  />
                                </td>
                            </tr>
                        	<tr class="prop">
                                <td valign="top" class="name">
                                    <label for="months"><g:message code="activity.months.label" default="Meses" /></label>
                                </td>
                                 <td valign="top" class="value ${hasErrors(bean: activityInstance, field: 'months', 'errors')}">
                                 	<input type="checkbox" name="months" value="Janeiro" ${activityInstance?.months?.contains("Janeiro") ? "checked" : ""} />Janeiro
                                    <input type="checkbox" name="months" value="Fevereiro" ${activityInstance?.months?.contains("Fevereiro") ? "checked" : ""} />Fevereiro
                                    <input type="checkbox" name="months" value="Março" ${activityInstance?.months?.contains("Março") ? "checked" : ""} />Março
                                    <input type="checkbox" name="months" value="Abril" ${activityInstance?.months?.contains("Abril") ? "checked" : ""}/>Abril
                                    <input type="checkbox" name="months" value="Maio" ${activityInstance?.months?.contains("Maio") ? "checked" : ""}/>Maio
                                    <input type="checkbox" name="months" value="Junho" ${activityInstance?.months?.contains("Junho") ? "checked" : ""}/>Junho
                                    <input type="checkbox" name="months" value="Julho" ${activityInstance?.months?.contains("Julho") ? "checked" : ""}/>Julho <br />
                                    <input type="checkbox" name="months" value="Agosto" ${activityInstance?.months?.contains("Agosto") ? "checked" : ""}/>Agosto
                                    <input type="checkbox" name="months" value="Setembro" ${activityInstance?.months?.contains("Setembro") ? "checked" : ""}/>Setembro
                                    <input type="checkbox" name="months" value="Outubro" ${activityInstance?.months?.contains("Outubro") ? "checked" : ""}/>Outubro
                                    <input type="checkbox" name="months" value="Novembro" ${activityInstance?.months?.contains("Novembro") ? "checked" : ""}/>Novembro
                                    <input type="checkbox" name="months" value="Dezembro" ${activityInstance?.months?.contains("Dezembro") ? "checked" : ""}/>Dezembro
                                </td>
                            </tr>
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="startDate"><g:message code="activity.startDate.label" default="Início" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: activityInstance, field: 'startDate', 'errors')}">
                                    <g:datePicker name="startDate" precision="day" value="${activityInstance?.startDate}"  />
                                </td>
                            </tr>
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="endDate"><g:message code="activity.endDate.label" default="Fim" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: activityInstance, field: 'endDate', 'errors')}">
                                    <g:datePicker name="endDate" precision="day" value="${activityInstance?.endDate}"  />
                                </td>
                            </tr>
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="status"><g:message code="activity.status.label" default="Status" /></label>
                                </td>
                                 <td valign="top" class="value ${hasErrors(bean: activityInstance, field: 'status', 'errors')}">
                                 	<select name="status">
									  	<option value="0" ${activityInstance?.status == 0 ? 'selected' : ''}>Não iniciada</option>
									  	<option value="1" ${activityInstance?.status == 1 ? 'selected' : ''}>Em andamento</option>
									  	<option value="2" ${activityInstance?.status == 2 ? 'selected' : ''}>Concluída</option>
									  	<option value="3" ${activityInstance?.status == 3 ? 'selected' : ''}>Abortada</option>
									</select>
                                </td>
                            </tr>
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="description"><g:message code="activity.description.label" default="Descri&ccedil;&atilde;o" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: activityInstance, field: 'description', 'errors')}">
                                    <g:textArea name="description" value="${activityInstance?.description}" />
                                </td>
                            </tr>
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="target"><g:message code="activity.target.label" default="Público Alvo" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: activityInstance, field: 'target', 'errors')}">
                                    <g:textArea name="target" value="${activityInstance?.target}" />
                                </td>
                            </tr>
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="reasons"><g:message code="activity.reasons.label" default="Justificativa" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: activityInstance, field: 'reasons', 'errors')}">
                                    <g:textArea name="reasons" value="${activityInstance?.reasons}" />
                                </td>
                            </tr>
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="expectedResults"><g:message code="activity.expectedResults.label" default="Resultados Esperados" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: activityInstance, field: 'expectedResults', 'errors')}">
                                   <g:textArea name="expectedResults" value="${activityInstance?.expectedResults}" />
                                </td>
                            </tr>
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="actualResults"><g:message code="activity.actualResults.label" default="Resultados Obtidos" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: activityInstance, field: 'actualResults', 'errors')}">
                                    <g:textArea name="actualResults" value="${activityInstance?.actualResults}" />
                                </td>
                            </tr>
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="partners"><g:message code="activity.partners.label" default="Colaboradores" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: activityInstance, field: 'partners', 'errors')}">
                                    <g:textArea name="partners" value="${activityInstance?.partners}" />
                                </td>
                            </tr>
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="sponsor"><g:message code="activity.sponsor.label" default="Responsável" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: activityInstance, field: 'sponsor', 'errors')}">
                                	<div class="selects">
	                                	<g:select class="from" from="${user.User.list() - activityInstance.sponsors}" optionKey="id" optionValue="nome" multiple="multiple" value="${activityInstance?.sponsors*.id}"  />
	                                	<g:select class="to" name="sponsors" from="${user.User.list()}" optionKey="id" optionValue="nome" multiple="multiple" value="${activityInstance?.sponsors*.id}"  />
	                                	<a href="#" id="to" onclick="return false"><img alt="Edit" src="${resource(dir:'images/icons',file:'to.png')}" /></a> <br />
		                                <a href="#" id="from" onclick="return false"><img alt="Edit" src="${resource(dir:'images/icons',file:'from.png')}" /></a>
	                                </div>
                                </td>
                            </tr>
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="comments"><g:message code="activity.comments.label" default="Comentários Gerais" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: activityInstance, field: 'comments', 'errors')}">
                                	<g:textArea name="comments" value="${activityInstance?.comments}" />
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><g:actionSubmit class="save" action="update" value="Salvar" /></span>
                </div>
            </g:form>
        </div>
        </div>
    </body>
</html>
